﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LIMS.BLL
{
    public class StudentManager
    {
        private static LIMS.IDAL.IStudent student = DALFactory.DataAccess<LIMS.IDAL.IStudent>.CreateObject();
        private static IDAL.IGrade grade = DALFactory.DataAccess<LIMS.IDAL.IGrade>.CreateObject();


        public static void AddStudent(LIMS.Model.Students stu)
        {
            student.Add(stu);
        }

        /// <summary>
        /// 根据学号、姓名或者默认获取学生信息
        /// </summary>
        /// <param name="stu"></param>
        /// <returns></returns>
        public static List<LIMS.Model.Students> SearchStudent(LIMS.Model.Students stu)
        {
            if (stu != null && stu.stuNo != null)
            {
                return student.FindByID(stu);
            }
            if (stu != null && !String.IsNullOrEmpty(stu.stuName))
            {
                return student.FindByName(stu);
            }
            return student.FindAll();
        }

        public static Boolean DeleteStudents(LIMS.Model.Students stu, List<LIMS.Model.Students> listStudents = null)
        {
            if (listStudents != null && listStudents.Count > 0)
            {
                return student.Remove(listStudents);
            }
            return student.Remove(stu);
        }

        public static Boolean UpdateStudent(LIMS.Model.Students stu)
        {
            return student.Modify(stu);
        }

        /// <summary>
        /// 获取所有班级ID和班级名称的键值对
        /// </summary>
        /// <returns></returns>
        public static Dictionary<Int32, String> GetClassIDAndNo()
        {
            return grade.FindIDandNo();
        }


    }
}
